import type { MaSearchItem } from "@mineadmin/search";
import MaDictSelect from "@/components/ma-dict-picker/ma-dict-select.vue";
import MaRemoteSelect from "@/components/ma-remote-select/index.vue";
import { page as getRodList } from "@/plugins/ai-warning/device/api/rdDeviceRod.ts";
import { page as getStandList } from "@/plugins/ai-warning/organization/api/rdOrganizeAreaStand.ts";

export default function getSearchItems(t: any): MaSearchItem[] {
  return [
    {
      label: "设备MAC地址",
      prop: "code",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "设备code" }) },
    },
    {
      label: "设备名称",
      prop: "name",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "设备name" }) },
    },
    // {
    //   label: "设备别名",
    //   prop: "dev_name",
    //   render: "input",
    //   renderProps: { placeholder: t("form.pleaseInput", { msg: "设备别名" }) },
    // },
    {
      label: "装置名称",
      prop: "rod_id",
      render: () => MaRemoteSelect,
      renderProps: {
        api: getRodList,
        apiParams: {
          page: 1,
          pageSize: 1000,
        },
        dataHandle: (response: any) => {
          if (response.code === 200 && response.data && response.data.list) {
            return response.data.list.map((rod: any) => ({
              label: rod.name,
              value: rod.id,
            }));
          }
          return [];
        },
        placeholder: "请选择装置",
        filterable: true,
        clearable: true,
      },
    },
    {
      label: "所属站点",
      prop: "stand_id",
      render: () => MaRemoteSelect,
      renderProps: {
        api: getStandList,
        apiParams: {
          page: 1,
          pageSize: 1000,
        },
        dataHandle: (response: any) => {
          if (response.code === 200 && response.data && response.data.list) {
            return response.data.list.map((stand: any) => ({
              label: stand.name,
              value: stand.id,
            }));
          }
          return [];
        },
        placeholder: "请选择所属站点",
        filterable: true,
        clearable: true,
      },
    },
  ];
}
